﻿using System;
using System.Data.Linq;
using System.Linq.Expressions;

namespace Stiline.DAL.Repositories
{
    public class UserRepository : BaseRepository<Entities.User, DbContext.User>
    {
        protected override Table<DbContext.User> GetTable()
        {
            return Context.Users;
        }

        protected override Expression<Func<DbContext.User, Entities.User>> GetConverter()
        {
            return e => new Entities.User
            {
                Id = e.Id,
                Name = e.Name,
                Password = e.Password,
                Email = e.Email
            };
        }

        protected override void UpdateEntry(DbContext.User dbEntity, Entities.User entity)
        {
            dbEntity.Id = entity.Id;
            dbEntity.Name = entity.Name;
            dbEntity.Password = entity.Password;
            dbEntity.Email = entity.Email;
        }
    }
}
